package com.cyc.common.config;

import com.cyc.common.annotation.valid.CheckRegion;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.HashSet;
import java.util.Set;

/**
 * @author chenyunchang
 * @version 1.0
 * @title
 * @date 2021/4/23 16:47
 * @Description:
 */
public class RegionValidator implements ConstraintValidator<CheckRegion,String>{

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        Set<Object> regionSet = new HashSet<>();
        regionSet.add("北京");
        regionSet.add("上海");
        regionSet.add("广州");
        return regionSet.contains(value);
    }
}
